package com.glory.erp.invoice.storedetail.action;

import java.util.List;

import com.glory.erp.invoice.storedetail.service.StoreDetailService;
import com.glory.erp.invoice.storedetail.bean.StoreDetail;
import com.glory.erp.invoice.storedetail.bean.StoreDetailQuery;
import com.glory.erp.auth.base.BaseAction;

public class StoreDetailAction extends BaseAction{
	public StoreDetail storeDetail = new StoreDetail();
	public StoreDetailQuery storeDetailQuery = new StoreDetailQuery();

	private StoreDetailService storeDetailService;
	public void setStoreDetailService(StoreDetailService storeDetailService) {
		this.storeDetailService = storeDetailService;
	}

	//列表
	public String list(){
		setDataTotal(storeDetailService.getCount(storeDetailQuery));
		List<StoreDetail> storeDetailList = storeDetailService.findAll(storeDetailQuery,pageNum,pageCount);
		put("storeDetailList", storeDetailList);
		return LIST;
	}

	//到添加
	public String addView(){
		if(storeDetail.getUuid()!=null){
			storeDetail = storeDetailService.findById(storeDetail.getUuid());
		}
		return ADD;
	}

	//添加
	public String saveAndUpdate(){
		if(storeDetail.getUuid() == null){
			storeDetailService.save(storeDetail);
		}else{
			storeDetailService.update(storeDetail);
		}
		return TO_LIST;
	}

	//删除
	public String delete(){
		storeDetailService.delete(storeDetail);
		return TO_LIST;
	}

}
